//
//  JPUserTool.m
//  JPShop
//
//  Created by 虎爷 on 2019/10/15.
//  Copyright © 2019 虎爷. All rights reserved.
//

#import "JPUserTool.h"
#define UserPassagePath [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:@"account.archive"]

@implementation JPUserTool

+(User *)user{
    return [NSKeyedUnarchiver unarchiveObjectWithFile:UserPassagePath];
}
+(void)clearUser{
    NSFileManager *fieManager = [NSFileManager defaultManager];
    BOOL isexist = [fieManager fileExistsAtPath:UserPassagePath];
    if (isexist) {
        [fieManager removeItemAtPath:UserPassagePath error:NULL];
    }
}
+(void)saveUser:(User *)user{
    [NSKeyedArchiver archiveRootObject:user toFile:UserPassagePath];
}



@end
